package cn.lingyangwl.agile.pay.common.utils;

import com.github.yitter.idgen.YitIdHelper;

/**
 * 序列号生成 工具类
 *
 * @author shenguangyang
 */
public class SeqUtils {
    private static final String PAY_ORDER_SEQ_PREFIX = "P";
    private static final String REFUND_ORDER_SEQ_PREFIX = "R";
    private static final String MHO_ORDER_SEQ_PREFIX = "M";
    private static final String TRANSFER_ID_SEQ_PREFIX = "T";
    private static final String DIVISION_BATCH_ID_SEQ_PREFIX = "D";

    /**
     * 生成支付订单号
     */
    public static String genPayOrderNo() {
        return PAY_ORDER_SEQ_PREFIX + YitIdHelper.nextId();
    }

    /**
     * 生成退款订单号
     */
    public static String genRefundOrderId() {
        return REFUND_ORDER_SEQ_PREFIX + YitIdHelper.nextId();
    }


    /**
     * 模拟生成商户订单号
     */
    public static String genMhoOrderId() {
        return MHO_ORDER_SEQ_PREFIX + YitIdHelper.nextId();
    }

    /**
     * 模拟生成商户订单号
     */
    public static String genTransferId() {
        return TRANSFER_ID_SEQ_PREFIX + YitIdHelper.nextId();
    }

    /**
     * 模拟生成分账批次号
     */
    public static String genDivisionBatchId() {
        return DIVISION_BATCH_ID_SEQ_PREFIX + YitIdHelper.nextId();
    }

    public static void main(String[] args) throws Exception {
        System.out.println(genTransferId());
        System.out.println(genRefundOrderId());
        Thread.sleep(1000);
        System.out.println(genMhoOrderId());
        System.out.println(genTransferId());
        Thread.sleep(1000);
        System.out.println(genDivisionBatchId());
    }
}
